import { Controller, Post as HttpPost, Get, Param, Req, UseGuards } from '@nestjs/common';
import { ApiOperation } from '@nestjs/swagger';
import { UserFavoriteService } from './user-favorite.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';

@Controller('favorite')

export class UserFavoriteController {
  constructor(private readonly favService: UserFavoriteService) {}

  @ApiOperation({ summary: '对某个帖子进行收藏' })
  @HttpPost(':postId')
  async favorite(@Param('postId') postId: number, @Req() req) {
    return this.favService.favorite(postId, req.user.id);
  }

  @ApiOperation({ summary: '获取用户收藏的帖子' })
  @Get('my')
  async getFavorites(@Req() req) {
    return this.favService.getFavorites(req.user.id);
  }
}
